<include file="Public:header" />
<div class="subnav">
  <div class="explain-col" style="position: relative; height:24px;">
  	<!--<span class="red">温馨提示：</span>为了避免不小心操作误删导致用户不能正常访问，暂时不开放山茶功能。-->
      <div class="content-menu" style="position: absolute; right: 30px;top: 5px;">
        <a href="javascript:openWinBox('__URL__/add','添加菜单')" class="add fb"><em>添加节点</em></a>
      </div>
  </div>
</div>
<!--subnav-->
<div class="pad-lr-10">
  <form name="myform" id="myform" action="__URL__/updateSort" method="post">
  <div class="table-list">
   <table width="100%" cellspacing="0" >
    <thead>
      <tr>
        <th width="38">排序</th>
        <th align='center' width='50'>ID</th>
        <th  width="220">节点结构 [i]<span style="cursor:pointer; margin-left:10px;" onclick="showMenu()" id="showMenu">(展开)</span></th>
        <th >名称</th>
        <th align='center'>显示名</th>
        <th align='center'>类型</th>
        <th align='center' width="30">状态</th>
        <th >管理操作</th>
      </tr>
    </thead>
    <tbody>
      <volist name="appList" id="vo">
        <tr class="topList level-1">
          <td align='center'><input name='sortArr[]' type='hidden' size='3' value='{$vo.sort}' class='input-text-c'><input name="idArr[]" type="hidden" value="{$vo.id}"></td>
          
          <td align='center'><font color="red">{$vo.id}</font></td>
          <td><span style=" cursor:pointer; font-weight:bolder; color:#F00" onclick="toggleList('{$vo.id}')">{$vo.title}</span><img src ="../Public/Images/icon/gear_disable.png" title="不在导航显示"></td>
          <td align='center'>{$vo.name}</td>
          <td align='center'>{$vo.title}</td>
          <td align='center'>{$vo.typeName}</td>
          <td align='center'><a href="javascript:changeStatus({$vo.id});" id="status-{$vo.id}" name="{$vo.status}" title="" class="status" >{$sv.statusName}</a></td>
          <td align='center'>【<a href="javascript:openWinBox('__URL__/add/id/{$vo.id}','{$vo.title}')">修改</a>】【<a href="javascript:openWinBox('__URL__/del/id/{$v.id}','{$v.name}')">删除</a>】</td>
        </tr>

        <volist name="vo.model" key="vokey" id="v">
          <tr class="list-{$vo.id} level-2">
            <td align='center'><input name='sortArr[]' type='text' size='3' value='{$v.sort}' class='input-text-c'><input name="idArr[]" type="hidden" value="{$v.id}">
</td>
            
            <td align='center'><font color="">{$v.id}</font></td>
            <td ><span style="margin-left:15px; font-weight:bolder;">{$v.title}</span></td>
            <td align='center'>{$v.name}</td>
            <td align='center'>{$v.title}</td>
            <td align='center'>{$v.typeName}</td>
            <td align='center'><a href="javascript:changeStatus({$v.id});" id="status-{$v.id}" name="{$v.status}" title="" class="status" >{$v.statusName}</a></td>
            <td align='center'>【<a href="javascript:openWinBox('__URL__/add/id/{$v.id}','{$v.title}')">修改</a>】【<a href="javascript:openWinBox('__URL__/del/id/{$v.id}','{$v.name}')">删除</a>】</td>
          </tr>
              <volist name="v.action" id="sv">
                <tr class="list-{$vo.id} level-3">
                  <td align='center'><input name='sortArr[]' type='text' size='3' value='{$sv.sort}' class='input-text-c'><input name="idArr[]" type="hidden" value="{$sv.id}"></td>
                  

                  <td align='center'><font color="">{$sv.id}</font></td>
                  <td ><span style="margin-left:30px;"><if condition="count($__LIST__)==$i">└─<else />├─</if>{$sv.title}</span></td>
                  <td align='center'>{$sv.name}</td>
                  <td align='center'>{$sv.title}</td>
                  <td align='center'>{$sv.typeName}</td>
                  <td align='center'><a href="javascript:changeStatus({$sv.id});" id="status-{$sv.id}" name="{$sv.status}" title="" class="status" >{$sv.statusName}</a></td>

                  <td align='center'>【<a href="javascript:openWinBox('__URL__/add/id/{$sv.id}','{$sv.title}')">修改</a>】【<a href="javascript:openWinBox('__URL__/del/id/{$sv.id}','{$sv.name}')">删除</a>】</td>
                </tr>
              </volist>
        </volist>
      </volist>
    </tbody>
   </table>
   <div class="btn">
  	<div id="pages">{$page}</div>
  	<input name="submit" type="submit" class="button" value="更新排序">&nbsp;
   </div>
  </div>
  </form>
</div>

</body>
</html>
<script language="JavaScript">
$(document).ready(function(e) {

	//赋予状态颜色
	$(".status").each(function(i, val) {
        var status = $(this).attr('name');
		if(status==1){
			$(this).addClass('blue');
		}else{
			$(this).addClass('red');
		}
    });

    $(function(){
		$('#myform').ajaxForm({
			beforeSubmit:  checkForm,
			success:       complete,
			dataType: 'json'
		});
		function checkForm(){
			return true;
		}

		function complete(data){
			art.dialog({id:'TNCICC',content: data.info,time: 1,icon:'succeed'});
			setTimeout(function(){location.reload();},1000);
		}
	})

});



function toggleList(id){
	$(".list-"+id).toggle()
}

function showMenu(){
	$(".level-2").toggle()
	$(".level-3").toggle()
	var status = $("#showMenu").text();
	if(status=='(伸缩)'){
		$("#showMenu").text('(展开)');
	}else{
		$("#showMenu").html('(伸缩)');
	}
}

function changeStatus(id){
	var statusId = $("#status-"+id).attr('name');
	$.get("__URL__/changeStatus/id/"+id+"/statusId/"+statusId, function(data) {
	if(statusId==1){
			$("#status-"+id).text('禁用');
			$("#status-"+id).attr('name',0);
			$("#status-"+id).attr('class','red');
		}else{
			$("#status-"+id).text('启用');
			$("#status-"+id).attr('name',1);
			$("#status-"+id).attr('class','blue');
		}
	});
}
</script>